<?php

class Service_Model_Sms
{
	private $id;
	private $message;
	private $mobileNumber;
	private $originator;
	private $timeCreating;
	
	
	/**
	 * @return the $timeCreating
	 */
	public function getTimeCreating() {
		return $this->timeCreating;
	}

	/**
	 * @param field_type $timeCreating
	 */
	public function setTimeCreating($timeCreating) {
		$this->timeCreating = $timeCreating;
	}

	/**
	 * @return the $id
	 */
	public function getId() {
		return $this->id;
	}

	/**
	 * @param field_type $id
	 */
	public function setId($id) {
		$this->id = $id;
		return $this;
	}

	public function __construct($message = null, $mobileNumber = null, $originator = null)
	{
		if($message && $mobileNumber && $originator)
		{
			$this->message = (string)$message;
			if(!$this->_checkNumber($mobileNumber)) //check if number valid
				throw new Exception("Bad format of mobile number.");
			else 
				$this->mobileNumber = $mobileNumber;
			$this->originator = (string)$originator;
		}
		$this->timeCreating = date("Y-m-d H-i-s");
	}


	/**
	 * @return the $message
	 */
	public function getMessage() {
		return $this->message;
	}

	/**
	 * @return the $mobileNumber
	 */
	public function getMobileNumber() {
		return $this->mobileNumber;
	}

	/**
	 * @return the $originator
	 */
	public function getOriginator() {
		return $this->originator;
	}

	/**
	 * @param field_type $message
	 */
	public function setMessage($message) {
		$this->message = $message;
		return $this;
	}

	/**
	 * @param field_type $mobileNumber
	 */
	public function setMobileNumber($mobileNumber) {
		if(!$this->_checkNumber($mobileNumber)) //check if number valid
			throw new Exception("Bad format of mobile number.");
		else 
			$this->mobileNumber = $mobileNumber;
		return $this;
	}

	/**
	 * @param field_type $originator
	 */
	public function setOriginator($originator) {
		$this->originator = $originator;
		return $this;
	}

	private function _checkNumber($number){
		return preg_match('/80\d{9}/is', $number);
	}
	
	
	

}

